package com.yidu.verycd_background;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * <p>Created with IntelliJ IDEA.</p>
 * <p>User: liandyao</p>
 * <p>Date: 2020-07-20</p>
 * <p>Time: 10:39</p>
 * <p>Description: swagger配置类</p>
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket api(){
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .pathMapping("/").select().apis(RequestHandlerSelectors.basePackage("com.yidu.verycd_background.controller"))
                .paths(PathSelectors.any()).build().apiInfo(info());
        return docket;
    }


    private ApiInfo info(){
        ApiInfo info = new ApiInfoBuilder()
                .title("springBoot集成swagger构建api文档-用户信息")
                .description("该文档提供了增删改查的方法说明以及测试")
                .version("1.0")
                .termsOfServiceUrl("http://yidu.com/verycd_background")
                .contact(new Contact("pyd","www.pyd.com","pyd@QQ.com"))
                .build()  ;
        return info ;
    }
}
